package com.yc.cloneDemo.shallowClone;

/**
 * Title: 浅克隆实体，学生类
 * 引用类型的浅克隆会影响原对象的值，
 * 基本类型不会影响<br>
 * Description: <br>
 * Author:陈圆(chenyuan@bosssoft.com.cn) <br>
 * Date:2020/8/28
 */
public class Student implements Cloneable{

    private Course course; // 引用类型，课程

    private String stuName; // 学生姓名
    private Integer stuNo; // 学生编号

    private int age; // 年龄

    public Course getCourse() {
        return course;
    }

    public void setCourse(Course course) {
        this.course = course;
    }

    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public Integer getStuNo() {
        return stuNo;
    }

    public void setStuNo(Integer stuNo) {
        this.stuNo = stuNo;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public Student clone() {
        Student student = null;
        try {
            student = (Student)super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return student;
    }

    @Override
    public String toString() {
        return "Student{" +
                "course=" + course +
                ", stuName='" + stuName + '\'' +
                ", stuNo=" + stuNo +
                ", age=" + age +
                '}';
    }
}
